package site.jlopen.controller.modules;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import site.jlopen.assets.config.ThreadAuthUser;
import site.jlopen.domain.node.event.KusciaNodeEvent;
import site.jlopen.entity.BaseResponse;
import site.jlopen.entity.req.NodeListReq;
import site.jlopen.entity.req.NodeReq;
import site.jlopen.kuscia.model.NodeVo;
import site.jlopen.service.BaseService;

@RestController
@RequestMapping("/node")
public class NodeController extends BaseService{

	@PostMapping("/create")
	public BaseResponse<String> create(@RequestBody NodeReq nodeReq) {
		return nodeService.create(ThreadAuthUser.id(), nodeReq);
	}

	@PostMapping("/createLite")
	public BaseResponse<NodeVo> createLite(@RequestBody NodeListReq nodeReq) {
		return nodeService.createLite(ThreadAuthUser.id(), nodeReq);
	}

	@PostMapping("/valid")
	public BaseResponse<String> valid(@RequestBody NodeReq nodeReq) {
		return nodeService.valid(ThreadAuthUser.id(), nodeReq);
	}

	@GetMapping("/list")
	public List<KusciaNodeEvent> list() {
		return nodeService.list(ThreadAuthUser.id());
	}

	@GetMapping("/masterList")
	public List<KusciaNodeEvent> masterList() {
		return nodeService.masterList(ThreadAuthUser.id());
	}

	@GetMapping("/remove")
	public BaseResponse<String> remove(Long nodeId) {
		return nodeService.deleteNode(nodeId);
	}

	@GetMapping("/status")
	public BaseResponse<String> status() {

		return new BaseResponse<String>().success("在线");
	}

	@GetMapping("/restatus")
	public BaseResponse<String> restatus(Long nodeId) {
		return nodeService.restatus(nodeId);
	}
}
